using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DBSourceTools
{
    public partial class NewProjectForm : Form
    {
        private string m_ProjectName;

        public string ProjectName
        {
            get { return m_ProjectName; }
            set { m_ProjectName = value; }
        }
        private string m_BaseDirectory;

        public string BaseDirectory
        {
            get { return m_BaseDirectory; }
            set { m_BaseDirectory = value; }
        }
        private DBConnectionLib.Database m_Database = null;

        public DBConnectionLib.Database Database
        {
            get { return m_Database; }
            set { m_Database = value; }
        }

        public NewProjectForm()
        {
            InitializeComponent();
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (this.m_folderBrowserDialog1.ShowDialog(this) == DialogResult.OK)
            {
                this.m_BaseDirectory = this.m_folderBrowserDialog1.SelectedPath;
                this.m_textBoxBaseDirectory.Text = this.m_BaseDirectory;
                CheckOKVisible();
            }
        }

        private void btnSelectDatabase_Click(object sender, EventArgs e)
        {
            NewDatabaseForm oNewDbForm = new NewDatabaseForm(true);
            if (oNewDbForm.ShowDialog(this) == DialogResult.OK)
            {
                this.m_Database = oNewDbForm.Database;
                this.m_textBoxDatabaseNick.Text = this.m_Database.NickName;
                CheckOKVisible();
            }
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            
        }

        private void CheckOKVisible()
        {
            if (String.IsNullOrEmpty(this.m_textBoxProjectName.Text))
            {
//                MessageBox.Show("Please specify a Project Name");
                return;
            }
            if (String.IsNullOrEmpty(this.m_textBoxBaseDirectory.Text))
            {
                //                MessageBox.Show("Please specify a Base Directory");
                return;
            }
            if (this.m_Database == null)
                return;
            this.btnOk.Enabled = true;
            this.ProjectName = this.m_textBoxProjectName.Text;

        }

        private void NewProjectForm_Load(object sender, EventArgs e)
        {
            this.btnOk.Enabled = false;
        }
    }
}